package com.线程;

public class ThreadLocalTest {



static    ThreadLocal<Long> longLocal = new ThreadLocal<Long>();


    private static void set (){

        longLocal.set(0L);
    }
    public static void main(String[] args) throws InterruptedException {

        set();
        for (int i = 0 ; i < 10;i++) {
            int finalI = i;
            Thread t =    new Thread(new Runnable() {
                @Override
                public void run() {

                        longLocal.set(Thread.currentThread().getId());


                        System.out.println(Thread.currentThread().getName() + ":"+finalI+"-" + longLocal.get()+"----"+longLocal);


                }
            });

            t.join();
            t.start();

        }


        System.out.println("main");
        System.out.println(longLocal);
        System.out.println(longLocal.get());
    }

}